{$CLEO .s}
{$INCLUDE_ONCE ../cleo_tester.inc}

script_name "0AC8" // allocate_memory
test("0AC8 (allocate_memory)", tests)
terminate_this_custom_script

function tests

    before_each(@allocate)
    after_each(@free)
    
    it("should return valid pointer", test1)
    it("should point to zero-filled mem in CLEO5", test2)
    return

    function test1
        // 0@ is set in before_each callback
        assert_ptr(0@)
        assert_neq(0@, 0x11223344)
    end
    
    function test2
        2@ = 0xCCCCCCCC
        2@ = read_memory 0@ {size} 4 {vp} false
        assert_eq(2@, 0)
    end

    :allocate
        0@ = 0x11223344
        0@ = allocate_memory {size} 4
    return

    :free
        free_memory {address} 0@
    return


end